from selenium import webdriver
from selenium.webdriver.common.by import By
import time

# 初始化浏览器
driver = webdriver.Chrome()
driver.maximize_window()

# 打开126的网页
driver.get("https://www.126.com/")
# 进入账号密码输入框所在表单
fram_ele = driver.find_element(By.XPATH, "//iframe[@frameborder='0']")
# driver.switch_to_frame(fram_ele)
driver.switch_to.frame(fram_ele)
# 定位账号输入框元素
ele = driver.find_element(By.XPATH, "//input[@name='email']")
# 输入框内输入内容
ele.send_keys("123456")
time.sleep(2)

# 点击-会员按钮
# driver.switch_to.parent_frame()
driver.switch_to.default_content()
driver.find_element(By.XPATH, "//a[text()='会员']").click()

# 关闭浏览器
time.sleep(5)
driver.quit()